<%@page import="com.is.export.control.SelectOptionValue"%>
<%@page import="java.util.LinkedHashMap"%>
<%@page import="com.is.control.HomeworkControl"%>
<%@page import="com.is.util.DesData"%>
<%@page import="com.is.control.AttendanceDetailControl"%>
<%@page import="com.is.control.ParamClassControl"%>
<%@page import="com.is.model.ParamStuyear"%>
<%@page import="com.is.control.ParamStuyearControl"%>
<%@page import="com.is.control.CourseClassControl"%>
<%@page import="com.is.model.CourseClass"%>
<%@page import="java.util.List"%>
<%@page import="com.is.control.StudentControl"%>
<%@page import="com.is.model.Student"%>
<%@page import="com.is.util.ParamUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.is.control.ParamCourseControl"%>
<%@page import="com.is.control.CourseScoreControl"%>
<%@page import="com.is.model.CourseScore"%>
<%@page import="com.is.export.model.ScoreExport"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.is.model.ParamCourseScoreGS"%>
<%@page import="com.is.control.ParamCourseScoreGSControl"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../resources/css/user_info.css" />
<style type="text/css">
	#caption{height:30px; line-height:30px; text-align:left;}
	#add_info{width:600px;}
	#add_info table{width:580px; margin:0 auto;}
	#add_info table caption{text-align:left;}
	table thead tr th{background:#7BC671;}
</style>
<title>个人成绩情况</title>
</head>
<body>
<%
         // 单个学生所有课程出席情况
         DesData des = new DesData();
        String stu=ParamUtil.getString(request,"stuId");
         int stuId = Integer.parseInt(des.decrypt(stu));
         //System.out.print("DDD"+stuId+"DDDD");
         Student s = StudentControl.getStudent(stuId);
         int classId = Integer.parseInt(s.getClassId());
         int stuyear = ParamUtil.getInt(request,"stuyear",ParamStuyearControl.getCurrentStuyearId());
         List<CourseClass> ccs = CourseClassControl.getAllCourseClassIdByClassIdAndStuyear(classId,stuyear);
         List<ScoreExport> exportList = new ArrayList<ScoreExport>();
 %>

 <div id="add_info">
 <form action="allCoursesOneStu.jsp" method="post">
 <table>
 	<caption>请选择：</caption>
 	<tr>
 		<td><select name="stuyear">
			 <%
			         List<ParamStuyear> years = ParamStuyearControl.getAllStuyear();
			         for(ParamStuyear ps:years){
			 %>
			 <option value="<%=ps.getId() %>" <%if(ps.getId()==stuyear)out.print("selected"); %>><%=ps.getStuyear() %></option>
			 <%} %>
			 </select>
		</td>
 		<td>
	 		<input type="hidden" value="<%=stu %>" name=stuId>
			<input type="submit" value="查询" />
		</td>
 		<td>
 			 <input type="button" value="导出结果"  onclick="window.location.href='/InterStu/servlet/ExportDo'" />
 		</td>
 	</tr>
 </table>
 <br/>
 </form>
 <form>
 <table>
 <caption><%=s.getChineseName() %>的成绩情况：</caption>
 <thead>
	 <tr>
		 <th>课程</th>
		 <th>出勤成绩</th>
		 <th>平时成绩</th>
		 <th>期中成绩</th>
		 <th>期末成绩</th>
		 <th>总成绩</th>
		 <th colspan="4">计算方式</th>
	 </tr>
 </thead>
 <tbody>
 <%
      for(CourseClass cc:ccs){
          CourseScore cs = CourseScoreControl.getCSByStuIdAndCourseId(cc.getId(),s.getId());
          ParamCourseScoreGS csgs = ParamCourseScoreGSControl.getGSByCourseClassId(cc.getId());
          String courseName  =ParamCourseControl.getCourseById(cc.getCourseId()).getCourseName();
          String attandance = (cs!=null)?cs.getAttendanceScore():"0.0";
	      String daily = (cs!=null)?cs.getDailyScore():"0.0";
	      String mid = (cs!=null)?cs.getMidtermScore():"0.0";
	      String finalS = (cs!=null)?cs.getFinalScore():"0.0";
		  String total = (cs!=null)?cs.getTotalScore():"0.0";
		  %>
		  <tr>
		  <td><%=courseName %></td>
		  <td><%=attandance %></td>
		 <td><%=daily%></td>
		 <td><%=mid %></td>
		 <td><%=finalS %></td>
		 <td><%=total %></td>
		 <td><%out.print(csgs!=null?"总=平时"+csgs.getDailyScore_per()+"%+期中"+csgs.getMiderScore_per()+"%+期末"+csgs.getFinalScore_per()+"%":"公式有误"); %></td>
		   </tr>
		  <%
		  ScoreExport se = new ScoreExport();
		  se.setCourseName(courseName);
		  se.setDailyScore(daily);
		  se.setFinalScore(finalS);
		  se.setMidtermScore(mid);
		  se.setTotalScore(total);
		  se.setStuName(s.getChineseName());
		  exportList.add(se);
		  }
		session.removeAttribute("exportList");
		session.setAttribute("exportList",exportList);
		session.removeAttribute("fileName");
		session.setAttribute("fileName",s.getChineseName()+ParamStuyearControl.getStuyear(stuyear).getStuyear()+"成绩情况");
		 LinkedHashMap<String,String> exportOps = SelectOptionValue.ScoreOptions();
		 session.removeAttribute("exportOps");
    	 session.setAttribute("exportOps",exportOps);
    	 session.removeAttribute("className");
    	 session.setAttribute("className","com.is.export.model.ScoreExport");
 %>
 </tbody>
 </table>
 <br/>
 </form>
 </div>
</body>
</html>